<script type="text/javascript" src="<?php $this->path('js/jquery.validate.min.js');?>"></script>
<script type="text/javascript" src="<?php $this->path('js/jquery.form.js');?>"></script>
<form id="registerf" class="form_style registed" onsubmit="return false" autocomplete="off" style="margin-top:0px">
	<div style="float:left;width:45%">
    	<div class="firstname">
    		<strong>First Name:</strong><sup class="surely">*</sup><br>
    		<input type="text" name="firstname" class="" value="" style="width:90%" placeholder="First Name...">
    	</div>
    	<div class="lastname">
    		<strong>Last Name:</strong><sup class="surely">*</sup><br>
    		<input type="text" name="lastname" class="" value="" style="width:90%" placeholder="Last Name...">
    	</div>
    	<div class="institution">
    		<strong>Institution:</strong><sup class="surely">*</sup><br>
    		<input type="text" name="institution" class="" value="" style="width:90%" placeholder="Institution...">
    	</div>
	</div>
	<div style="float:right;width:45%">
    	<div class="address">
    		<strong>Address:</strong><sup class="surely">*</sup><br>
    		<input type="text" name="address" class="" value="" style="width:90%" placeholder="Address...">
    	</div>
    	<div class="email">
    		<strong>Email:</strong><sup class="surely">*</sup><br>
    		<input type="text" name="email" class="" value="" style="width:90%" placeholder="Email...">
    	</div>
    	<div class="contact">
    		<strong>Contact:</strong><sup class="surely">*</sup><br>
    		<input type="text" name="contact" class="" value="" style="width:90%" placeholder="Contact...">
    	</div>
	</div>
	<sup class="surely">*</sup><span>Required Field</span>
	<input type="submit" value="Create" style="float:right;">
	<div class="clear"></div>
</form>	
<script>
$( "#registerf" ).validate({
  	rules: {
  		firstname: {
  			required: true
  		},
  		lastname: {
  			required: true
  		},
  		email: {
  			required: true,
  			email: true
  		}
  	}
});
$( "#registerf" ).submit(function() {
	f = $('input[name=firstname]').val();
    l = $('input[name=lastname]').val();
    i = $('input[name=institution]').val();
    e = $('input[name=email]').val();
    a = $('input[name=address]').val();
    c = $('input[name=contact]').val();
	$.post('?module=register&action=customer',{new:1, firstname:f, lastname:l, institution:i, email:e, address:a, contact:c},function(data){
		if(data.length > 0)
			alert(data);
		else{
			if($('#cussearch').length > 0)
				$('#cussearch').trigger('keyup');
			$('#form_new_customer').dialog('close');
		}
	});   
	return false;
});
</script>